package com.cuijq.ms.singleton.generator;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @Classname IdGenerator
 * @Description 饿汉式
 * @Date 2021/5/5 9:37
 * @Created by CuiJQ
 */
public class IdGenerator {

  private AtomicLong id = new AtomicLong(0);
  private static final IdGenerator instance = new IdGenerator();

  private IdGenerator() {
  }

  public static IdGenerator getInstance() {
    return instance;
  }

  public long getId() {
    return id.incrementAndGet();
  }
}
